package de.tabuma.pm.project.view;

import de.tabuma.lib.*;
import de.tabuma.pm.*;
import de.tabuma.customer.entity.*;
import java.io.*;
import java.util.*;
import java.util.logging.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author alefen
 */
public class create extends tabumaview {

    public create(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }

    @Override
    public void processRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {

        List<Customer> cList = (List<Customer>) request.getAttribute(constants.customerList);

        String addContent = "Add project to list.";
        String projectName = "project name";
        String projectDescription = "description";
        String projectCustomer = "customer";
        String add = "Add";
        String back = "Back";

        out.println("<form action=\""+this.getServlet()+"\">");
        out.println("<div class=\"contentContent\">");
        out.println(addContent);
        out.println("</div>");

        out.println("<div class=\"contentContent\">");
        out.println("<div class=\"col1\">");
        out.println("<div class=\"col1_head\">"+projectName+"</div>");
        out.println("<div class=\"col1_content\"><input type=\"text\" name=\""+constants.paramProjectName+"\" value=\"\"/></div>");
        out.println("</div>");
        out.println("<div class=\"col2\">");
        out.println("<div class=\"col2_head\">"+projectCustomer+"</div>");
        out.println("<div class=\"col2_content\"><select name=\""+constants.paramProjectCustomerId+"\">");
        for(int i=0;i<cList.size();i++) {
            out.println("<option value=\""+cList.get(i).getId()+"\">"+cList.get(i).getName()+"</option>");
        }
        out.println("</select></div>");
        out.println("</div>");
        out.println("<div class=\"col1\">");
        out.println("<div class=\"col1_head\">"+projectDescription+"</div>");
        out.println("<div class=\"col1_content\"><textarea name=\""+constants.paramProjectDescription+"\" cols=\"20\" rows=\"2\"></textarea></div>");
        out.println("</div>");
        out.println("<div class=\"col2\">");
        out.println("</div>");
        out.println("<div class=\"col1\"></div>");
        out.println("<div class=\"col2\"></div>");
        out.println("<div class=\"col1\"></div>");
        out.println("<div class=\"col2\"></div>");
        out.println("</div>");
        out.println("<div class=\"contentContent\">");
        Enumeration enu = this.getParameter().keys();
        while(enu.hasMoreElements()) {
            String key = (String) enu.nextElement();
            String value = (String) this.getParameter().get(key);
            out.println("<input type=\"hidden\" name=\""+key+"\" value=\""+value+"\"/>");
        }
        out.println("<input type=\"hidden\" name=\""+constants.paramAction+"\" value=\""+constants.ACTION_CREATE+"\"/>");
        out.println("<input type=\"hidden\" name=\""+constants.paramProjectCreate+"\" value=\"true\"/>");
        out.println("<input type=\"submit\" class=\"button\" value=\""+add+"\"/>");        out.println("<input type=\"button\" class=\"button\" value=\""+back+"\" onClick=\"javascript:history.back()\"/>");
        out.println("</div>");
        out.println("</form>");

    }

    

}
